package com.ng.finance.api.entity;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ng.finance.common.util.DateUtils;
import org.apache.commons.lang.StringUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

import static com.ng.finance.common.util.DateUtils.YMDHMS_BREAK_HALF;

/**
 * <p>
 *
 * </p>
 *
 * @author 83673
 * @since 2018-09-14
 */
public class UserPay extends Model<com.ng.finance.api.entity.UserPay> {


    public static final String ID = "id";
    public static final String PAY_TYPE = "pay_type";
    public static final String PAY_REMARK = "pay_remark";
    public static final String PAY_TIME = "pay_time";
    public static final String PAY_MONEY = "pay_money";
    public static final String USER_ID = "user_id";
    public static final String USER_NAME = "user_name";
    public static final String USER_PIC = "user_pic";
    public static final String USER_PHONE = "user_phone";
    public static final String OPENID = "openid";
    public static final String UINIONID = "unionid";
    public static final String WECHAT_PIC = "wechat_pic";
    public static final String WECHAT_NICK = "wechat_nick";
    public static final String DEL_FLAG = "del_flag";
    public static final String CREATE_TIME = "create_time";
    public static final String LOOK_STATE = "look_state";
    public static final String PAY_PIC = "pay_pic";
    public static final String READ_ROLE = "read_role";
    private static final long serialVersionUID = 1L;
    /**
     * 消费类型 1--交通   2--餐饮   3---生活  4---娱乐 5---工具
     */
    @NotNull(message = "消费类型不能为空!")
    private Integer payType;
    /**
     * 消费说明
     */
    @NotBlank(message = "消费说明不能为空!")
    private String payRemark;
    /**
     * 消费人id
     */
    private Long userId;
    /**
     * 消费人姓名
     */
    private String userName;
    /**
     * 是否已阅   1--已阅   2---未阅
     */
    private Integer lookState;
    /**
     * 发票 消费凭证
     */
    @NotBlank(message = "消费凭证不能为空!")
    private String payPic;
    @TableId(value = "id", type = IdType.ID_WORKER)

    private Long id;
    /**
     * 消费 日期
     */
    @NotNull(message = "消费日期不能为空!")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date payTime;
    /**
     * 消费金额
     */

    @NotNull(message = " 请填写消费金额!")
    private String payMoney;
    /**
     * 消费人头像
     */
    @JsonIgnore
    private String userPic;
    /**
     * 消费人手机号
     */
    @JsonIgnore
    private String userPhone;


    private Integer eatId;
    /**
     * 用户唯一标识
     */
    @JsonIgnore
    private String openid;
    /**
     * 用户在开放平台的唯一标识符，在满足 UnionID 下发条件的情况下会返回
     */
    @NotBlank(message = "unionid不能为空")
    private String unionid;
    /**
     * 微信头像
     */
    @JsonIgnore
    private String wechatPic;
    /**
     * 微信昵称
     */
    @JsonIgnore
    private String wechatNick;
    @TableLogic
    @JsonIgnore
    private Integer delFlag;
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    @TableField(exist = false)
    private String[] payPicArry;
    private String address;
    @TableField(exist = false)
    private String pid;
    /**
     * 一起消费的人数
     */
    private String totalPerson;

    /**
     * 是否可以查看  1--可以  2--不可以
     *
     * @return
     */
    public UserPay(Integer payType, String payRemark, String payTime, String payMoney, Long userId, String userName,
                   String userPic, String userPhone, String openid, String unionid, String wechatPic,
                   String wechatNick, Integer delFlag, Integer lookState, String payPic, String address, String totalPerson) {
        this.payType = payType;
        this.payRemark = payRemark;

        this.payTime = DateUtils.getDate(payTime, YMDHMS_BREAK_HALF);
        this.payMoney = payMoney;
        this.userId = userId;
        this.userName = userName;
        this.userPic = userPic;
        this.userPhone = userPhone;
        this.openid = openid;
        this.unionid = unionid;
        this.wechatPic = wechatPic;
        this.wechatNick = wechatNick;
        this.delFlag = delFlag;
        this.lookState = lookState;
        this.payPic = payPic;
        this.address = address;
        this.totalPerson = totalPerson;
        this.address = address;

    }

    public UserPay(Long id, Integer lookState) {
        this.id = id;
        this.lookState = lookState;
    }

    public UserPay(String id, Integer lookState) {
        this.id = Long.parseLong(id);
        this.lookState = lookState;
    }

    public UserPay(Long id) {
        this.id = id;
    }

    public UserPay() {
    }

    public Integer getEatId() {
        return eatId;
    }

    public void setEatId(Integer eatId) {
        this.eatId = eatId;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getPayType() {
        return payType;
    }

    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    public String getPayRemark() {
        return payRemark;
    }

    public void setPayRemark(String payRemark) {
        this.payRemark = payRemark;
    }

    public Date getPayTime() {
        return payTime;
    }

    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPic() {
        return userPic;
    }

    public void setUserPic(String userPic) {
        this.userPic = userPic;
    }

    public String getUserPhone() {
        return userPhone;
    }

    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone;
    }

    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    public String getWechatPic() {
        return wechatPic;
    }

    public void setWechatPic(String wechatPic) {
        this.wechatPic = wechatPic;
    }

    public String getWechatNick() {
        return wechatNick;
    }

    public void setWechatNick(String wechatNick) {
        this.wechatNick = wechatNick;
    }

    public Integer getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(Integer delFlag) {
        this.delFlag = delFlag;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getLookState() {
        return lookState;
    }

    public void setLookState(Integer lookState) {
        this.lookState = lookState;
    }

    public String getPayPic() {
        return payPic;
    }

    public void setPayPic(String payPic) {
        this.payPic = payPic;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPid() {
        return this.id.toString();
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public String getTotalPerson() {
        return totalPerson;
    }

    public void setTotalPerson(String totalPerson) {
        this.totalPerson = totalPerson;
    }

    public String[] getPayPicArry() {
        if (StringUtils.isNotBlank(payPic)) {
            return payPic.split(";");
        }

        return new String[]{};
    }

    public void setPayPicArry(String[] payPicArry) {
        this.payPicArry = payPicArry;
    }

    public String getPayMoney() {
        return payMoney;
    }

    public void setPayMoney(String payMoney) {
        this.payMoney = payMoney;
    }

    public String getUnionid() {
        return unionid;
    }

    public void setUnionid(String unionid) {
        this.unionid = unionid;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @Override
    public String toString() {
        return "UserPay{" +
                "id=" + id +
                ", payType=" + payType +
                ", payRemark=" + payRemark +
                ", payTime=" + payTime +
                ", payMoney=" + payMoney +
                ", userId=" + userId +
                ", userName=" + userName +
                ", userPic=" + userPic +
                ", userPhone=" + userPhone +
                ", openid=" + openid +
                ", unionid=" + unionid +
                ", wechatPic=" + wechatPic +
                ", wechatNick=" + wechatNick +
                ", delFlag=" + delFlag +
                ", createTime=" + createTime +
                ", lookState=" + lookState +
                ", payPic=" + payPic +
                ", address=" + address +
                ", totalPerson=" + totalPerson +
                ", eatId" + eatId +

                "}";
    }
}
